package dao;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import entity.ZhuCe;

public class RegisterDao {
	private SessionFactory sessionFactory;


	
	 public SessionFactory getSessionFactory() {
		return sessionFactory;
	}



	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}


         Session session=null;
	
	public void addUser(ZhuCe zhuce){
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationcontext.xml");
		sessionFactory=(SessionFactory) ctx.getBean("sessionFactory");
		session=sessionFactory.openSession();
		session.beginTransaction();
		session.save(zhuce);
		session.getTransaction().commit();
		session.getTransaction().commit();
		session.getTransaction().commit();
		session.close();
		
		
		
	}
}
